package com.ellricky.market.ui

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.andr.common.ui.fragment.BaseToolBarFragment
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.ui.ErCodeActivity
import com.ellricky.baselib.ui.clue.AddClueActivity
import com.ellricky.baselib.ui.clue.MyClueSearchActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.market.R
import kotlinx.android.synthetic.main.market_fragment_clue.*

class MarketClueFragment : BaseToolBarFragment<Void, BasePresenter<Void>>() {

    companion object {
        fun newInstance(): MarketClueFragment {
            val fragment = MarketClueFragment()
            val bundle = Bundle()
            fragment.arguments = bundle
            return fragment
        }
    }

    override fun getContentLayout(): Int {
        return R.layout.market_fragment_clue
    }

    override fun initUIView(root: View?) {
        super.initUIView(root)
        setLeftIb(R.drawable.base_icon_ercode)
        setRightBtn(0)
        mTvTitle.text = "线索管理"

        initTab()
    }

    override fun onClickBtnRight() {
        super.onClickBtnRight()
        EAppUtil.jumpPageWithNoParam(this, AddClueActivity::class.java)
    }

    override fun onClickBtnRightLeft() {
        super.onClickBtnRightLeft()
        EAppUtil.jumpPageWithNoParam(this, MyClueSearchActivity::class.java)
    }


    override fun onClickView(view: View) {
        super.onClickView(view)
        when (view) {
            mIbBack -> EAppUtil.jumpPageWithNoParam(this, ErCodeActivity::class.java)
        }
    }

    private fun initTab() {
        val frgList = arrayListOf<Fragment>(
            MarketCluePoolFragment.newInstance(),
            MarketSchoolClueFragment.newInstance(),
            MarketClueTaskFragment.newInstance()
        )

        val tList = listOf("线索池", "校区", "任务")
        tabLayout.setUp(childFragmentManager, frgList, tList, vp)
    }
}